﻿using System.Collections.Generic;
using FikriKibar.Business.Abstract;
using FikriKibar.Common.Helpers;
using FikriKibar.DataAccess;
using FikriKibar.DataAccess.Abstract;
using FikriKibar.Entities.Concrete;

namespace FikriKibar.Business.Concrete
{
    public class LanguageManager : ILanguageService
    {
        #region Global Declarations
        private readonly ILanguageDal _languageDal = new EfLanguageDal();

        #endregion
        #region Methods
        public List<string> GetAllLanguageCodes()
        {
            List<string> list;
            const string cacheKey = "FikriKibar.Business.Concrete.LanguageManager.GetAllLanguageCodes";
            if (CacheHelper.Get(cacheKey) != null)
            {
                list = (List<string>)CacheHelper.Get(cacheKey);
            }
            else
            {
                list = _languageDal.GetAllLanguageCodes();
                CacheHelper.Add(cacheKey, list);
            }
            return list;
        }
        public List<Language> GetAll()
        {
            List<Language> list;
            const string cacheKey = "FikriKibar.Business.Concrete.LanguageManager.GetAll";
            if (CacheHelper.Get(cacheKey) != null)
            {
                list = (List<Language>)CacheHelper.Get(cacheKey);
            }
            else
            {
                list = _languageDal.Filter(e => e.IsApproved);
                CacheHelper.Add(cacheKey, list);
            }
            return list;
        }

        #endregion

    }
}
